package com.itheima.myfinal;

public class TextFinal {
    public static void main(String[] args) {
        //final修饰变量
        final int a = 10;
//        a = 20; //无法在被赋值
        //final修饰方法,方法不能被重写


        //如果被final修饰的类不能跟该地址值,但是能改属性值
       final Student stu = new Student();
        stu.setName("张三");
        stu.setId("78979");
        stu.setId("527775");
      //  stu = new Student();
    }
}
class Student{
    //如果在成员变量被赋值前在无参构造里面进行赋值也是可以的
    private final int a ;//必须要在无参有参全部赋值
    private String name;
    private String id;

    public Student() {
       a = 20;//无参赋值
    }

    public Student(String name, String id) {
        a = 20; //必须在无参带参都要赋值
        this.name = name;
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }
}
